home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / include / win32 / Winioctl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-08  |  29.8 KB  |  811 lines

  1. /*++ BUILD Version: 0013    // Increment this if a change has global effects
  2.  
  3. Copyright (c) 1990-1996  Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     winioctl.h
  8.  
  9. Abstract:
  10.  
  11.     This module defines the 32-Bit Windows Device I/O control codes.
  12.  
  13. Revision History:
  14.  
  15. --*/
  16.  
  17. #ifndef _WINIOCTL_
  18. #define _WINIOCTL_
  19.  
  20.  
  21. #ifndef _DEVIOCTL_
  22. #define _DEVIOCTL_
  23.  
  24. // begin_ntddk begin_nthal begin_ntifs
  25. //
  26. // Define the various device type values.  Note that values used by Microsoft
  27. // Corporation are in the range 0-32767, and 32768-65535 are reserved for use
  28. // by customers.
  29. //
  30.  
  31. #define DEVICE_TYPE DWORD
  32.  
  33. #define FILE_DEVICE_BEEP                0x00000001
  34. #define FILE_DEVICE_CD_ROM              0x00000002
  35. #define FILE_DEVICE_CD_ROM_FILE_SYSTEM  0x00000003
  36. #define FILE_DEVICE_CONTROLLER          0x00000004
  37. #define FILE_DEVICE_DATALINK            0x00000005
  38. #define FILE_DEVICE_DFS                 0x00000006
  39. #define FILE_DEVICE_DISK                0x00000007
  40. #define FILE_DEVICE_DISK_FILE_SYSTEM    0x00000008
  41. #define FILE_DEVICE_FILE_SYSTEM         0x00000009
  42. #define FILE_DEVICE_INPORT_PORT         0x0000000a
  43. #define FILE_DEVICE_KEYBOARD            0x0000000b
  44. #define FILE_DEVICE_MAILSLOT            0x0000000c
  45. #define FILE_DEVICE_MIDI_IN             0x0000000d
  46. #define FILE_DEVICE_MIDI_OUT            0x0000000e
  47. #define FILE_DEVICE_MOUSE               0x0000000f
  48. #define FILE_DEVICE_MULTI_UNC_PROVIDER  0x00000010
  49. #define FILE_DEVICE_NAMED_PIPE          0x00000011
  50. #define FILE_DEVICE_NETWORK             0x00000012
  51. #define FILE_DEVICE_NETWORK_BROWSER     0x00000013
  52. #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
  53. #define FILE_DEVICE_NULL                0x00000015
  54. #define FILE_DEVICE_PARALLEL_PORT       0x00000016
  55. #define FILE_DEVICE_PHYSICAL_NETCARD    0x00000017
  56. #define FILE_DEVICE_PRINTER             0x00000018
  57. #define FILE_DEVICE_SCANNER             0x00000019
  58. #define FILE_DEVICE_SERIAL_MOUSE_PORT   0x0000001a
  59. #define FILE_DEVICE_SERIAL_PORT         0x0000001b
  60. #define FILE_DEVICE_SCREEN              0x0000001c
  61. #define FILE_DEVICE_SOUND               0x0000001d
  62. #define FILE_DEVICE_STREAMS             0x0000001e
  63. #define FILE_DEVICE_TAPE                0x0000001f
  64. #define FILE_DEVICE_TAPE_FILE_SYSTEM    0x00000020
  65. #define FILE_DEVICE_TRANSPORT           0x00000021
  66. #define FILE_DEVICE_UNKNOWN             0x00000022
  67. #define FILE_DEVICE_VIDEO               0x00000023
  68. #define FILE_DEVICE_VIRTUAL_DISK        0x00000024
  69. #define FILE_DEVICE_WAVE_IN             0x00000025
  70. #define FILE_DEVICE_WAVE_OUT            0x00000026
  71. #define FILE_DEVICE_8042_PORT           0x00000027
  72. #define FILE_DEVICE_NETWORK_REDIRECTOR  0x00000028
  73. #define FILE_DEVICE_BATTERY             0x00000029
  74. #define FILE_DEVICE_BUS_EXTENDER        0x0000002a
  75. #define FILE_DEVICE_MODEM               0x0000002b
  76. #define FILE_DEVICE_VDM                 0x0000002c
  77. #define FILE_DEVICE_MASS_STORAGE        0x0000002d
  78.  
  79. //
  80. // Macro definition for defining IOCTL and FSCTL function control codes.  Note
  81. // that function codes 0-2047 are reserved for Microsoft Corporation, and
  82. // 2048-4095 are reserved for customers.
  83. //
  84.  
  85. #define CTL_CODE( DeviceType, Function, Method, Access ) (                 \
  86.     ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
  87. )
  88.  
  89. //
  90. // Define the method codes for how buffers are passed for I/O and FS controls
  91. //
  92.  
  93. #define METHOD_BUFFERED                 0
  94. #define METHOD_IN_DIRECT                1
  95. #define METHOD_OUT_DIRECT               2
  96. #define METHOD_NEITHER                  3
  97.  
  98. //
  99. // Define the access check value for any access
  100. //
  101. //
  102. // The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
  103. // ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
  104. // constants *MUST* always be in sync.
  105. //
  106.  
  107.  
  108. #define FILE_ANY_ACCESS                 0
  109. #define FILE_READ_ACCESS          ( 0x0001 )    // file & pipe
  110. #define FILE_WRITE_ACCESS         ( 0x0002 )    // file & pipe
  111.  
  112. // end_ntddk end_nthal end_ntifs
  113.  
  114. #endif // _DEVIOCTL_
  115.  
  116.  
  117. #ifndef _NTDDSTOR_H_
  118. #define _NTDDSTOR_H_
  119.  
  120.  
  121. //
  122. // IoControlCode values for disk devices.
  123. //
  124.  
  125. #define IOCTL_STORAGE_BASE                FILE_DEVICE_MASS_STORAGE
  126.  
  127. //
  128. // The following device control codes are common for all class drivers.  They
  129. // should be used in place of the older IOCTL_DISK, IOCTL_CDROM and IOCTL_TAPE
  130. // common codes
  131. //
  132.  
  133. #define IOCTL_STORAGE_CHECK_VERIFY     CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  134. #define IOCTL_STORAGE_MEDIA_REMOVAL    CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  135. #define IOCTL_STORAGE_EJECT_MEDIA      CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  136. #define IOCTL_STORAGE_LOAD_MEDIA       CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  137. #define IOCTL_STORAGE_RESERVE          CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  138. #define IOCTL_STORAGE_RELEASE          CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  139. #define IOCTL_STORAGE_FIND_NEW_DEVICES CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  140. #define IOCTL_STORAGE_GET_MEDIA_TYPES  CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  141.  
  142. //
  143. // IOCTL_STORAGE_MEDIA_REMOVAL disables the mechanism
  144. // on a storage device that ejects media. This function
  145. // may or may not be supported on storage devices that
  146. // support removable media.
  147. //
  148. // TRUE means prevent media from being removed.
  149. // FALSE means allow media removal.
  150. //
  151.  
  152. typedef struct _PREVENT_MEDIA_REMOVAL {
  153.     BOOLEAN PreventMediaRemoval;
  154. } PREVENT_MEDIA_REMOVAL, *PPREVENT_MEDIA_REMOVAL;
  155.  
  156. #endif // _NTDDSTOR_H_
  157.  
  158. //
  159. // IoControlCode values for disk devices.
  160. //
  161.  
  162. #define IOCTL_DISK_BASE                 FILE_DEVICE_DISK
  163. #define IOCTL_DISK_GET_DRIVE_GEOMETRY   CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
  164. #define IOCTL_DISK_GET_PARTITION_INFO   CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
  165. #define IOCTL_DISK_SET_PARTITION_INFO   CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  166. #define IOCTL_DISK_GET_DRIVE_LAYOUT     CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
  167. #define IOCTL_DISK_SET_DRIVE_LAYOUT     CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  168. #define IOCTL_DISK_VERIFY               CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS)
  169. #define IOCTL_DISK_FORMAT_TRACKS        CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  170. #define IOCTL_DISK_REASSIGN_BLOCKS      CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  171. #define IOCTL_DISK_PERFORMANCE          CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
  172. #define IOCTL_DISK_IS_WRITABLE          CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS)
  173. #define IOCTL_DISK_LOGGING              CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS)
  174. #define IOCTL_DISK_FORMAT_TRACKS_EX     CTL_CODE(IOCTL_DISK_BASE, 0x000b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  175. #define IOCTL_DISK_HISTOGRAM_STRUCTURE  CTL_CODE(IOCTL_DISK_BASE, 0x000c, METHOD_BUFFERED, FILE_ANY_ACCESS)
  176. #define IOCTL_DISK_HISTOGRAM_DATA       CTL_CODE(IOCTL_DISK_BASE, 0x000d, METHOD_BUFFERED, FILE_ANY_ACCESS)
  177. #define IOCTL_DISK_HISTOGRAM_RESET      CTL_CODE(IOCTL_DISK_BASE, 0x000e, METHOD_BUFFERED, FILE_ANY_ACCESS)
  178. #define IOCTL_DISK_REQUEST_STRUCTURE    CTL_CODE(IOCTL_DISK_BASE, 0x000f, METHOD_BUFFERED, FILE_ANY_ACCESS)
  179. #define IOCTL_DISK_REQUEST_DATA         CTL_CODE(IOCTL_DISK_BASE, 0x0010, METHOD_BUFFERED, FILE_ANY_ACCESS)
  180.  
  181. #if(_WIN32_WINNT >= 0x0400)
  182. #define IOCTL_DISK_CONTROLLER_NUMBER    CTL_CODE(IOCTL_DISK_BASE, 0x0011, METHOD_BUFFERED, FILE_ANY_ACCESS)
  183.  
  184. //
  185. // IOCTL support for SMART drive fault prediction.
  186. //
  187.  
  188. #define SMART_GET_VERSION               CTL_CODE(IOCTL_DISK_BASE, 0x0020, METHOD_BUFFERED, FILE_READ_ACCESS)
  189. #define SMART_SEND_DRIVE_COMMAND        CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  190. #define SMART_RCV_DRIVE_DATA            CTL_CODE(IOCTL_DISK_BASE, 0x0022, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  191. #endif /* _WIN32_WINNT >= 0x0400 */
  192.  
  193.  
  194. //
  195. // The following device control codes are common for all class drivers.  The
  196. // functions codes defined here must match all of the other class drivers.
  197. //
  198. // Warning: these codes will be replaced in the future by equivalent
  199. // IOCTL_STORAGE codes
  200. //
  201.  
  202. #define IOCTL_DISK_CHECK_VERIFY     CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  203. #define IOCTL_DISK_MEDIA_REMOVAL    CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  204. #define IOCTL_DISK_EJECT_MEDIA      CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  205. #define IOCTL_DISK_LOAD_MEDIA       CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  206. #define IOCTL_DISK_RESERVE          CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  207. #define IOCTL_DISK_RELEASE          CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  208. #define IOCTL_DISK_FIND_NEW_DEVICES CTL_CODE(IOCTL_DISK_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  209. #define IOCTL_DISK_GET_MEDIA_TYPES CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  210.  
  211. //
  212. // Define the partition types returnable by known disk drivers.
  213. //
  214.  
  215. #define PARTITION_ENTRY_UNUSED          0x00      // Entry unused
  216. #define PARTITION_FAT_12                0x01      // 12-bit FAT entries
  217. #define PARTITION_XENIX_1               0x02      // Xenix
  218. #define PARTITION_XENIX_2               0x03      // Xenix
  219. #define PARTITION_FAT_16                0x04      // 16-bit FAT entries
  220. #define PARTITION_EXTENDED              0x05      // Extended partition entry
  221. #define PARTITION_HUGE                  0x06      // Huge partition MS-DOS V4
  222. #define PARTITION_IFS                   0x07      // IFS Partition
  223. #define PARTITION_FAT32                 0x0B      // FAT32
  224. #define PARTITION_FAT32_XINT13          0x0C      // FAT32 using extended int13 services
  225. #define PARTITION_XINT13                0x0E      // Win95 partition using extended int13 services
  226. #define PARTITION_XINT13_EXTENDED       0x0F      // Same as type 5 but uses extended int13 services
  227. #define PARTITION_PREP                  0x41      // PowerPC Reference Platform (PReP) Boot Partition
  228. #define PARTITION_UNIX                  0x63      // Unix
  229.  
  230. #define VALID_NTFT                      0xC0      // NTFT uses high order bits
  231.  
  232. //
  233. // The high bit of the partition type code indicates that a partition
  234. // is part of an NTFT mirror or striped array.
  235. //
  236.  
  237. #define PARTITION_NTFT                  0x80     // NTFT partition
  238.  
  239. //
  240. // The following macro is used to determine which partitions should be
  241. // assigned drive letters.
  242. //
  243.  
  244. //++
  245. //
  246. // BOOLEAN
  247. // IsRecognizedPartition(
  248. //     IN DWORD PartitionType
  249. //     )
  250. //
  251. // Routine Description:
  252. //
  253. //     This macro is used to determine to which partitions drive letters
  254. //     should be assigned.
  255. //
  256. // Arguments:
  257. //
  258. //     PartitionType - Supplies the type of the partition being examined.
  259. //
  260. // Return Value:
  261. //
  262. //     The return value is TRUE if the partition type is recognized,
  263. //     otherwise FALSE is returned.
  264. //
  265. //--
  266.  
  267. #define IsRecognizedPartition( PartitionType ) (       \
  268.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_12)) ||  \
  269.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT_16)) ||  \
  270.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_IFS)) ||  \
  271.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_HUGE)) ||  \
  272.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32)) ||  \
  273.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_FAT32_XINT13)) ||  \
  274.      ((PartitionType & PARTITION_NTFT) && ((PartitionType & ~0xC0) == PARTITION_XINT13)) ||  \
  275.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT_12) ||  \
  276.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT_16) ||  \
  277.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_IFS)    ||  \
  278.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_HUGE)    ||  \
  279.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT32)  || \
  280.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_FAT32_XINT13) || \
  281.      ((PartitionType & ~PARTITION_NTFT) == PARTITION_XINT13) )
  282.  
  283. //++
  284. //
  285. // BOOLEAN
  286. // IsContainerPartition(
  287. //     IN DWORD PartitionType
  288. //     )
  289. //
  290. // Routine Description:
  291. //
  292. //     This macro is used to determine to which partition types are actually
  293. //     containers for other partitions (ie, extended partitions).
  294. //
  295. // Arguments:
  296. //
  297. //     PartitionType - Supplies the type of the partition being examined.
  298. //
  299. // Return Value:
  300. //
  301. //     The return value is TRUE if the partition type is a container,
  302. //     otherwise FALSE is returned.
  303. //
  304. //--
  305.  
  306. #define IsContainerPartition( PartitionType ) \
  307.     ((PartitionType == PARTITION_EXTENDED) || (PartitionType == PARTITION_XINT13_EXTENDED))
  308.  
  309. //
  310. // Define the media types supported by the driver.
  311. //
  312.  
  313. typedef enum _MEDIA_TYPE {
  314.     Unknown,                // Format is unknown
  315.     F5_1Pt2_512,            // 5.25", 1.2MB,  512 bytes/sector
  316.     F3_1Pt44_512,           // 3.5",  1.44MB, 512 bytes/sector
  317.     F3_2Pt88_512,           // 3.5",  2.88MB, 512 bytes/sector
  318.     F3_20Pt8_512,           // 3.5",  20.8MB, 512 bytes/sector
  319.     F3_720_512,             // 3.5",  720KB,  512 bytes/sector
  320.     F5_360_512,             // 5.25", 360KB,  512 bytes/sector
  321.     F5_320_512,             // 5.25", 320KB,  512 bytes/sector
  322.     F5_320_1024,            // 5.25", 320KB,  1024 bytes/sector
  323.     F5_180_512,             // 5.25", 180KB,  512 bytes/sector
  324.     F5_160_512,             // 5.25", 160KB,  512 bytes/sector
  325.     RemovableMedia,         // Removable media other than floppy
  326.     FixedMedia,             // Fixed hard disk media
  327.     F3_120M_512             // 3.5", 120M Floppy
  328. } MEDIA_TYPE, *PMEDIA_TYPE;
  329.  
  330. //
  331. // Define the input buffer structure for the driver, when
  332. // it is called with IOCTL_DISK_FORMAT_TRACKS.
  333. //
  334.  
  335. typedef struct _FORMAT_PARAMETERS {
  336.    MEDIA_TYPE MediaType;
  337.    DWORD StartCylinderNumber;
  338.    DWORD EndCylinderNumber;
  339.    DWORD StartHeadNumber;
  340.    DWORD EndHeadNumber;
  341. } FORMAT_PARAMETERS, *PFORMAT_PARAMETERS;
  342.  
  343. //
  344. // Define the BAD_TRACK_NUMBER type. An array of elements of this type is
  345. // returned by the driver on IOCTL_DISK_FORMAT_TRACKS requests, to indicate
  346. // what tracks were bad during formatting. The length of that array is
  347. // reported in the `Information' field of the I/O Status Block.
  348. //
  349.  
  350. typedef WORD   BAD_TRACK_NUMBER;
  351. typedef WORD   *PBAD_TRACK_NUMBER;
  352.  
  353. //
  354. // Define the input buffer structure for the driver, when
  355. // it is called with IOCTL_DISK_FORMAT_TRACKS_EX.
  356. //
  357.  
  358. typedef struct _FORMAT_EX_PARAMETERS {
  359.    MEDIA_TYPE MediaType;
  360.    DWORD StartCylinderNumber;
  361.    DWORD EndCylinderNumber;
  362.    DWORD StartHeadNumber;
  363.    DWORD EndHeadNumber;
  364.    WORD   FormatGapLength;
  365.    WORD   SectorsPerTrack;
  366.    WORD   SectorNumber[1];
  367. } FORMAT_EX_PARAMETERS, *PFORMAT_EX_PARAMETERS;
  368.  
  369. //
  370. // The following structure is returned on an IOCTL_DISK_GET_DRIVE_GEOMETRY
  371. // request and an array of them is returned on an IOCTL_DISK_GET_MEDIA_TYPES
  372. // request.
  373. //
  374.  
  375. typedef struct _DISK_GEOMETRY {
  376.     LARGE_INTEGER Cylinders;
  377.     MEDIA_TYPE MediaType;
  378.     DWORD TracksPerCylinder;
  379.     DWORD SectorsPerTrack;
  380.     DWORD BytesPerSector;
  381. } DISK_GEOMETRY, *PDISK_GEOMETRY;
  382.  
  383. //
  384. // The following structure is returned on an IOCTL_DISK_GET_PARTITION_INFO
  385. // and an IOCTL_DISK_GET_DRIVE_LAYOUT request.  It is also used in a request
  386. // to change the drive layout, IOCTL_DISK_SET_DRIVE_LAYOUT.
  387. //
  388.  
  389. typedef struct _PARTITION_INFORMATION {
  390.     LARGE_INTEGER StartingOffset;
  391.     LARGE_INTEGER PartitionLength;
  392.     DWORD HiddenSectors;
  393.     DWORD PartitionNumber;
  394.     BYTE  PartitionType;
  395.     BOOLEAN BootIndicator;
  396.     BOOLEAN RecognizedPartition;
  397.     BOOLEAN RewritePartition;
  398. } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
  399.  
  400. //
  401. // The following structure is used to change the partition type of a
  402. // specified disk partition using an IOCTL_DISK_SET_PARTITION_INFO
  403. // request.
  404. //
  405.  
  406. typedef struct _SET_PARTITION_INFORMATION {
  407.     BYTE  PartitionType;
  408. } SET_PARTITION_INFORMATION, *PSET_PARTITION_INFORMATION;
  409.  
  410. //
  411. // The following structures is returned on an IOCTL_DISK_GET_DRIVE_LAYOUT
  412. // request and given as input to an IOCTL_DISK_SET_DRIVE_LAYOUT request.
  413. //
  414.  
  415. typedef struct _DRIVE_LAYOUT_INFORMATION {
  416.     DWORD PartitionCount;
  417.     DWORD Signature;
  418.     PARTITION_INFORMATION PartitionEntry[1];
  419. } DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION;
  420.  
  421. //
  422. // The following structure is passed in on an IOCTL_DISK_VERIFY request.
  423. // The offset and length parameters are both given in bytes.
  424. //
  425.  
  426. typedef struct _VERIFY_INFORMATION {
  427.     LARGE_INTEGER StartingOffset;
  428.     DWORD Length;
  429. } VERIFY_INFORMATION, *PVERIFY_INFORMATION;
  430.  
  431. //
  432. // The following structure is passed in on an IOCTL_DISK_REASSIGN_BLOCKS
  433. // request.
  434. //
  435.  
  436. typedef struct _REASSIGN_BLOCKS {
  437.     WORD   Reserved;
  438.     WORD   Count;
  439.     DWORD BlockNumber[1];
  440. } REASSIGN_BLOCKS, *PREASSIGN_BLOCKS;
  441.  
  442. #if(_WIN32_WINNT >= 0x0400)
  443. //
  444. // IOCTL_DISK_CONTROLLER_NUMBER returns the controller and disk
  445. // number for the handle.  This is used to determine if a disk
  446. // is attached to the primary or secondary IDE controller.
  447. //
  448.  
  449. typedef struct _DISK_CONTROLLER_NUMBER {
  450.     DWORD ControllerNumber;
  451.     DWORD DiskNumber;
  452. } DISK_CONTROLLER_NUMBER, *PDISK_CONTROLLER_NUMBER;
  453. #endif /* _WIN32_WINNT >= 0x0400 */
  454.  
  455. ///////////////////////////////////////////////////////
  456. //                                                   //
  457. // The following structures define disk performance  //
  458. // statistics: specifically the locations of all the //
  459. // reads and writes which have occured on the disk.  //
  460. //                                                   //
  461. // To use these structures, you must issue an IOCTL_ //
  462. // DISK_HIST_STRUCTURE (with a DISK_HISTOGRAM) to    //
  463. // obtain the basic histogram information. The       //
  464. // number of buckets which must allocated is part of //
  465. // this structure. Allocate the required number of   //
  466. // buckets and call an IOCTL_DISK_HIST_DATA to fill  //
  467. // in the data                                       //
  468. //                                                   //
  469. ///////////////////////////////////////////////////////
  470.  
  471. #define HIST_NO_OF_BUCKETS  24
  472.  
  473. typedef struct _HISTOGRAM_BUCKET {
  474.     DWORD       Reads;
  475.     DWORD       Writes;
  476. } HISTOGRAM_BUCKET, *PHISTOGRAM_BUCKET;
  477.  
  478. #define HISTOGRAM_BUCKET_SIZE   sizeof(HISTOGRAM_BUCKET)
  479.  
  480. typedef struct _DISK_HISTOGRAM {
  481.     LARGE_INTEGER   DiskSize;
  482.     LARGE_INTEGER   Start;
  483.     LARGE_INTEGER   End;
  484.     LARGE_INTEGER   Average;
  485.     LARGE_INTEGER   AverageRead;
  486.     LARGE_INTEGER   AverageWrite;
  487.     DWORD           Granularity;
  488.     DWORD           Size;
  489.     DWORD           ReadCount;
  490.     DWORD           WriteCount;
  491.     PHISTOGRAM_BUCKET  Histogram;
  492. } DISK_HISTOGRAM, *PDISK_HISTOGRAM;
  493.  
  494. #define DISK_HISTOGRAM_SIZE sizeof(DISK_HISTOGRAM)
  495.  
  496. ///////////////////////////////////////////////////////
  497. //                                                   //
  498. // The following structures define disk debugging    //
  499. // capabilities. The IOCTLs are directed to one of   //
  500. // the two disk filter drivers.                      //
  501. //                                                   //
  502. // DISKPERF is a utilty for collecting disk request  //
  503. // statistics.                                       //
  504. //                                                   //
  505. // SIMBAD is a utility for injecting faults in       //
  506. // IO requests to disks.                             //
  507. //                                                   //
  508. ///////////////////////////////////////////////////////
  509.  
  510. //
  511. // The following structure is exchanged on an IOCTL_DISK_GET_PERFORMANCE
  512. // request. This ioctl collects summary disk request statistics used
  513. // in measuring performance.
  514. //
  515.  
  516. typedef struct _DISK_PERFORMANCE {
  517.         LARGE_INTEGER BytesRead;
  518.         LARGE_INTEGER BytesWritten;
  519.         LARGE_INTEGER ReadTime;
  520.         LARGE_INTEGER WriteTime;
  521.         DWORD ReadCount;
  522.         DWORD WriteCount;
  523.         DWORD QueueDepth;
  524. } DISK_PERFORMANCE, *PDISK_PERFORMANCE;
  525.  
  526. //
  527. // This structure defines the disk logging record. When disk logging
  528. // is enabled, one of these is written to an internal buffer for each
  529. // disk request.
  530. //
  531.  
  532. typedef struct _DISK_RECORD {
  533.    LARGE_INTEGER ByteOffset;
  534.    LARGE_INTEGER StartTime;
  535.    LARGE_INTEGER EndTime;
  536.    PVOID VirtualAddress;
  537.    DWORD NumberOfBytes;
  538.    BYTE  DeviceNumber;
  539.    BOOLEAN ReadRequest;
  540. } DISK_RECORD, *PDISK_RECORD;
  541.  
  542. //
  543. // The following structure is exchanged on an IOCTL_DISK_LOG request.
  544. // Not all fields are valid with each function type.
  545. //
  546.  
  547. typedef struct _DISK_LOGGING {
  548.     BYTE  Function;
  549.     PVOID BufferAddress;
  550.     DWORD BufferSize;
  551. } DISK_LOGGING, *PDISK_LOGGING;
  552.  
  553. //
  554. // Disk logging functions
  555. //
  556. // Start disk logging. Only the Function and BufferSize fields are valid.
  557. //
  558.  
  559. #define DISK_LOGGING_START    0
  560.  
  561. //
  562. // Stop disk logging. Only the Function field is valid.
  563. //
  564.  
  565. #define DISK_LOGGING_STOP     1
  566.  
  567. //
  568. // Return disk log. All fields are valid. Data will be copied from internal
  569. // buffer to buffer specified for the number of bytes requested.
  570. //
  571.  
  572. #define DISK_LOGGING_DUMP     2
  573.  
  574. //
  575. // DISK BINNING
  576. //
  577. // DISKPERF will keep counters for IO that falls in each of these ranges.
  578. // The application determines the number and size of the ranges.
  579. // Joe Lin wanted me to keep it flexible as possible, for instance, IO
  580. // sizes are interesting in ranges like 0-4096, 4097-16384, 16385-65536, 65537+.
  581. //
  582.  
  583. #define DISK_BINNING          3
  584.  
  585. //
  586. // Bin types
  587. //
  588.  
  589. typedef enum _BIN_TYPES {
  590.     RequestSize,
  591.     RequestLocation
  592. } BIN_TYPES;
  593.  
  594. //
  595. // Bin ranges
  596. //
  597.  
  598. typedef struct _BIN_RANGE {
  599.     LARGE_INTEGER StartValue;
  600.     LARGE_INTEGER Length;
  601. } BIN_RANGE, *PBIN_RANGE;
  602.  
  603. //
  604. // Bin definition
  605. //
  606.  
  607. typedef struct _PERF_BIN {
  608.     DWORD NumberOfBins;
  609.     DWORD TypeOfBin;
  610.     BIN_RANGE BinsRanges[1];
  611. } PERF_BIN, *PPERF_BIN ;
  612.  
  613. //
  614. // Bin count
  615. //
  616.  
  617. typedef struct _BIN_COUNT {
  618.     BIN_RANGE BinRange;
  619.     DWORD BinCount;
  620. } BIN_COUNT, *PBIN_COUNT;
  621.  
  622. //
  623. // Bin results
  624. //
  625.  
  626. typedef struct _BIN_RESULTS {
  627.     DWORD NumberOfBins;
  628.     BIN_COUNT BinCounts[1];
  629. } BIN_RESULTS, *PBIN_RESULTS;
  630.  
  631. #if(_WIN32_WINNT >= 0x0400)
  632. //
  633. // Data structures for SMART drive fault prediction.
  634. //
  635. // GETVERSIONINPARAMS contains the data returned from the
  636. // Get Driver Version function.
  637. //
  638.  
  639. #pragma pack(1)
  640. typedef struct _GETVERSIONINPARAMS {
  641.         BYTE     bVersion;               // Binary driver version.
  642.         BYTE     bRevision;              // Binary driver revision.
  643.         BYTE     bReserved;              // Not used.
  644.         BYTE     bIDEDeviceMap;          // Bit map of IDE devices.
  645.         DWORD   fCapabilities;          // Bit mask of driver capabilities.
  646.         DWORD   dwReserved[4];          // For future use.
  647. } GETVERSIONINPARAMS, *PGETVERSIONINPARAMS, *LPGETVERSIONINPARAMS;
  648. #pragma pack()
  649.  
  650. //
  651. // Bits returned in the fCapabilities member of GETVERSIONINPARAMS
  652. //
  653.  
  654. #define CAP_ATA_ID_CMD          1       // ATA ID command supported
  655. #define CAP_ATAPI_ID_CMD        2       // ATAPI ID command supported
  656. #define CAP_SMART_CMD           4       // SMART commannds supported
  657.  
  658. //
  659. // IDE registers
  660. //
  661.  
  662. #pragma pack(1)
  663. typedef struct _IDEREGS {
  664.         BYTE     bFeaturesReg;           // Used for specifying SMART "commands".
  665.         BYTE     bSectorCountReg;        // IDE sector count register
  666.         BYTE     bSectorNumberReg;       // IDE sector number register
  667.         BYTE     bCylLowReg;             // IDE low order cylinder value
  668.         BYTE     bCylHighReg;            // IDE high order cylinder value
  669.         BYTE     bDriveHeadReg;          // IDE drive/head register
  670.         BYTE     bCommandReg;            // Actual IDE command.
  671.         BYTE     bReserved;                      // reserved for future use.  Must be zero.
  672. } IDEREGS, *PIDEREGS, *LPIDEREGS;
  673. #pragma pack()
  674.  
  675. //
  676. // Valid values for the bCommandReg member of IDEREGS.
  677. //
  678.  
  679. #define ATAPI_ID_CMD    0xA1            // Returns ID sector for ATAPI.
  680. #define ID_CMD          0xEC            // Returns ID sector for ATA.
  681. #define SMART_CMD       0xB0            // Performs SMART cmd.
  682.                                         // Requires valid bFeaturesReg,
  683.                                         // bCylLowReg, and bCylHighReg
  684.  
  685. //
  686. // Cylinder register defines for SMART command
  687. //
  688.  
  689. #define SMART_CYL_LOW   0x4F
  690. #define SMART_CYL_HI    0xC2
  691.  
  692.  
  693. //
  694. // SENDCMDINPARAMS contains the input parameters for the
  695. // Send Command to Drive function.
  696. //
  697.  
  698. #pragma pack(1)
  699. typedef struct _SENDCMDINPARAMS {
  700.         DWORD   cBufferSize;            // Buffer size in bytes
  701.         IDEREGS irDriveRegs;            // Structure with drive register values.
  702.         BYTE     bDriveNumber;           // Physical drive number to send
  703.                                                                 // command to (0,1,2,3).
  704.         BYTE     bReserved[3];           // Reserved for future expansion.
  705.         DWORD   dwReserved[4];          // For future use.
  706.         BYTE     bBuffer[1];                     // Input buffer.
  707. } SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS;
  708. #pragma pack()
  709.  
  710. //
  711. // Status returned from driver
  712. //
  713.  
  714. #pragma pack(1)
  715. typedef struct _DRIVERSTATUS {
  716.         BYTE     bDriverError;           // Error code from driver,
  717.                                                                 // or 0 if no error.
  718.         BYTE     bIDEError;                      // Contents of IDE Error register.
  719.                                                                 // Only valid when bDriverError
  720.                                                                 // is SMART_IDE_ERROR.
  721.         BYTE     bReserved[2];           // Reserved for future expansion.
  722.         DWORD   dwReserved[2];          // Reserved for future expansion.
  723. } DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS;
  724. #pragma pack()
  725.  
  726. //
  727. // bDriverError values
  728. //
  729.  
  730. #define SMART_NO_ERROR          0       // No error
  731. #define SMART_IDE_ERROR         1       // Error from IDE controller
  732. #define SMART_INVALID_FLAG      2       // Invalid command flag
  733. #define SMART_INVALID_COMMAND   3       // Invalid command byte
  734. #define SMART_INVALID_BUFFER    4       // Bad buffer (null, invalid addr..)
  735. #define SMART_INVALID_DRIVE     5       // Drive number not valid
  736. #define SMART_INVALID_IOCTL     6       // Invalid IOCTL
  737. #define SMART_ERROR_NO_MEM      7       // Could not lock user's buffer
  738. #define SMART_INVALID_REGISTER  8       // Some IDE Register not valid
  739. #define SMART_NOT_SUPPORTED     9       // Invalid cmd flag set
  740. #define SMART_NO_IDE_DEVICE     10      // Cmd issued to device not present
  741.                                         // although drive number is valid
  742.  
  743. #pragma pack(1)
  744. typedef struct _SENDCMDOUTPARAMS {
  745.         DWORD                   cBufferSize;            // Size of bBuffer in bytes
  746.         DRIVERSTATUS            DriverStatus;           // Driver status structure.
  747.         BYTE                    bBuffer[1];             // Buffer of arbitrary length in which to store the data read from the                                                                                  // drive.
  748. } SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS;
  749. #pragma pack()
  750.  
  751.  
  752. #define READ_ATTRIBUTE_BUFFER_SIZE  512
  753. #define IDENTIFY_BUFFER_SIZE        512
  754. #define READ_THRESHOLD_BUFFER_SIZE  512
  755.  
  756. //
  757. // Feature register defines for SMART "sub commands"
  758. //
  759.  
  760. #define READ_ATTRIBUTES         0xD0
  761. #define READ_THRESHOLDS         0xD1
  762. #define ENABLE_DISABLE_AUTOSAVE 0xD2
  763. #define SAVE_ATTRIBUTE_VALUES   0xD3
  764. #define EXECUTE_OFFLINE_DIAGS   0xD4
  765. #define ENABLE_SMART            0xD8
  766. #define DISABLE_SMART           0xD9
  767. #define RETURN_SMART_STATUS     0xDA
  768. #endif /* _WIN32_WINNT >= 0x0400 */
  769.  
  770.  
  771.  
  772. #define IOCTL_SERIAL_LSRMST_INSERT      CTL_CODE(FILE_DEVICE_SERIAL_PORT,31,METHOD_BUFFERED,FILE_ANY_ACCESS)
  773.  
  774.  
  775. //
  776. // The following values follow the escape designator in the
  777. // data stream if the LSRMST_INSERT mode has been turned on.
  778. //
  779. #define SERIAL_LSRMST_ESCAPE     ((BYTE )0x00)
  780.  
  781. //
  782. // Following this value is the contents of the line status
  783. // register, and then the character in the RX hardware when
  784. // the line status register was encountered.
  785. //
  786. #define SERIAL_LSRMST_LSR_DATA   ((BYTE )0x01)
  787.  
  788. //
  789. // Following this value is the contents of the line status
  790. // register.  No error character follows
  791. //
  792. #define SERIAL_LSRMST_LSR_NODATA ((BYTE )0x02)
  793.  
  794. //
  795. // Following this value is the contents of the modem status
  796. // register.
  797. //
  798. #define SERIAL_LSRMST_MST        ((BYTE )0x03)
  799.  
  800. #define FSCTL_LOCK_VOLUME               CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
  801. #define FSCTL_UNLOCK_VOLUME             CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
  802. #define FSCTL_DISMOUNT_VOLUME           CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
  803. #define FSCTL_MOUNT_DBLS_VOLUME         CTL_CODE(FILE_DEVICE_FILE_SYSTEM,13, METHOD_BUFFERED, FILE_ANY_ACCESS)
  804. #define FSCTL_GET_COMPRESSION           CTL_CODE(FILE_DEVICE_FILE_SYSTEM,15, METHOD_BUFFERED, FILE_ANY_ACCESS)
  805. #define FSCTL_SET_COMPRESSION           CTL_CODE(FILE_DEVICE_FILE_SYSTEM,16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  806. #define FSCTL_READ_COMPRESSION          CTL_CODE(FILE_DEVICE_FILE_SYSTEM,17, METHOD_NEITHER,  FILE_READ_DATA)
  807. #define FSCTL_WRITE_COMPRESSION         CTL_CODE(FILE_DEVICE_FILE_SYSTEM,18, METHOD_NEITHER,  FILE_WRITE_DATA)
  808.  
  809. #endif // _WINIOCTL_
  810.  
  811.